package net.oschina.app.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.adapter.TextAdapter;
import net.oschina.app.base.BaseFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by admin on 2017/7/11.
 */

public class DefaultFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {

    @BindView(R.id.swipe_refresh_widget)
    SwipeRefreshLayout swipeRefreshWidget;
    Unbinder unbinder;
    @BindView(R.id.rcv_news_zixun)
    RecyclerView rcvNewsZixun;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        unbinder = ButterKnife.bind(this, inflater.inflate(R.layout.fragment_default, container, false));
        return inflater.inflate(R.layout.fragment_default, container, false);
    }


    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        swipeRefreshWidget.setColorSchemeColors(Color.parseColor("#ff0000"),
                Color.parseColor("#00ff00"), Color.parseColor("#0000ff"),
                Color.parseColor("#ffff00"));
        swipeRefreshWidget.setOnRefreshListener(this);

        LinearLayoutManager manager = new LinearLayoutManager(getActivity());
        manager.setOrientation(RecyclerView.VERTICAL);
        rcvNewsZixun.setLayoutManager(manager);
        rcvNewsZixun.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
            }
        });

        TextAdapter adapter = new TextAdapter();
        rcvNewsZixun.setAdapter(adapter);
    }



    @Override
    public void onRefresh() {

    }
}
